package cn.com.cetccst.messagecenter.inboxmessage;

import cn.com.cetccst.uicomponents.binding.app.DataBindingConfig;
import cn.com.cetccst.uicomponents.binding.app.DataBindingFragment;

import cn.com.cetccst.messagecenter.BR;
import cn.com.cetccst.messagecenter.R;
import cn.com.cetccst.messagecenter.databinding.FragmentInboxMessageBinding;


public class InboxMessageFragment extends DataBindingFragment<FragmentInboxMessageBinding> {
    private InboxMessageViewModel viewModel;

    @Override
    protected void initViewModel() {
        viewModel = getFragmentScopeViewModel(InboxMessageViewModel.class);
    }

    @Override
    public void onResume() {
        super.onResume();
        viewModel.readAll();
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (!hidden) {
            viewModel.readAll();
        }
    }

    @Override
    protected DataBindingConfig getDataBindingConfig() {
        InboxMessageAdapter adapter = new InboxMessageAdapter(getContext());
        return new DataBindingConfig(R.layout.fragment_inbox_message, BR.viewModel, viewModel)
                .addBindingParam(BR.adapter, adapter);
    }
}
